package com.rr.utils.core;


import lombok.NoArgsConstructor;

@NoArgsConstructor
public class PageDomain
{
    /** 当前记录起始索引 */
    private Integer pageNum;

    @Override
    public String toString() {
        return "PageDomain{" +
                "pageNum=" + pageNum +
                ", pageSize=" + pageSize +
                ", orderByColumn='" + orderByColumn + '\'' +
                ", isAsc='" + isAsc + '\'' +
                ", reasonable=" + reasonable +
                '}';
    }

    /** 每页显示记录数 */
    private Integer pageSize;

    /** 排序列 */
    private String orderByColumn;

    /** 排序的方向desc或者asc */
    private String isAsc = "desc";

    /** 分页参数合理化 */
    private Boolean reasonable = true;


    public Integer getPageNum()
    {
        return pageNum;
    }

    public void setPageNum(Integer pageNum)
    {
        this.pageNum = pageNum;
    }

    public Integer getPageSize()
    {
        return pageSize;
    }

    public void setPageSize(Integer pageSize)
    {
        this.pageSize = pageSize;
    }

    public String getOrderByColumn()
    {
        return orderByColumn;
    }

    public void setOrderByColumn(String orderByColumn)
    {
        this.orderByColumn = orderByColumn;
    }

    public String getIsAsc()
    {
        return isAsc;
    }

    public void setIsAsc(String isAsc) {
        this.isAsc = isAsc;
    }
    private  PageDomain (Builder builder) {

         this.pageNum = builder.pageNum;
          this.pageSize = builder.pageSize;
          this.orderByColumn = builder.orderByColumn;
           this.isAsc = builder.isAsc;
            this.reasonable = builder.reasonable;
    }


    /**
     * 建造者模式
     */

    public static class Builder {
         private Integer pageNum;
        private Integer pageSize;
        private String orderByColumn;
        private String isAsc = "desc";
        private Boolean reasonable = true;

        public Builder pageNum(Integer pageNum) {
            this.pageNum = pageNum;
            return this;
        }

        public Builder pageSize(Integer pageSize) {
            this.pageSize = pageSize;
            return this;
        }

        public Builder orderByColumn(String orderByColumn) {
            this.orderByColumn = orderByColumn;
            return this;
        }

        public Builder isAsc(String isAsc) {
            this.isAsc = isAsc;
            return this;
        }

        public Builder reasonable(Boolean reasonable) {
            this.reasonable = reasonable;
            return this;
        }

        public PageDomain build() {
            return new PageDomain(this);
        }
    }


}